'''
Created on Jan 17, 2011

@author: dexen
'''


import os
import tempfile
import SimpleHTTPServer
import SocketServer

PORT = 8000

from dexen.system.common import utils
from dexen.system.server import TOP_DIR

def start():
    if os.path.exists(TOP_DIR):
        utils.rmentry(TOP_DIR)
    os.mkdir(TOP_DIR)
    #arch_path = os.path.join(tempfile.gettempdir(), "Dexen_Archive")
    #print arch_path
    os.chdir(TOP_DIR)
    Handler = SimpleHTTPServer.SimpleHTTPRequestHandler    
    httpd = SocketServer.TCPServer(("", PORT), Handler)
    print "serving at port", PORT
    httpd.serve_forever()
    
def main():
    start()

if __name__ == "__main__":
    main()
